package com.fancy.learncenter.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;

import com.fancy.learncenter.activity.base.BaseActivity;
import com.fancy.learncenter.bean.BaseDataBean;
import com.fancy.learncenter.net.HttpMehtod;
import com.fancy.learncenter.net.IdeaObserver;
import com.fancy.learncenter.utils.ToastUtil;
import com.superservice.lya.R;

import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class TrainApplyActivity extends BaseActivity {

    String activityId;
    @Bind(R.id.contact_tv)
    EditText contactTv;
    @Bind(R.id.moblie_tv)
    EditText moblieTv;
    @Bind(R.id.company_tv)
    EditText companyTv;
    @Bind(R.id.work_tv)
    EditText workTv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_apply, getResources().getColor(R.color.toolbar_color));
        ButterKnife.bind(this);
        initToolbar("信息填写");
        activityId = getIntent().getStringExtra("trainId");
    }

    private void getDatas() {
        Map map = new HashMap();
        map.put("trainId", activityId);
        map.put("company", companyTv.getText().toString());
        map.put("contact", moblieTv.getText().toString());
        map.put("position", workTv.getText().toString());
        map.put("realName", contactTv.getText().toString());
        HttpMehtod.getInstance().trainApply(map, new IdeaObserver<BaseDataBean>() {

            @Override
            public void onSuccess(BaseDataBean trainApplyDetailDataBeanBaseDataBean) {

                Intent intent = new Intent(TrainApplyActivity.this, ActivityApplySuccessActivity.class);
                startActivity(intent);

                finish();

            }

            @Override
            public void onFail(int errorCode) {

            }
        });
    }

    @OnClick(R.id.confrim)
    public void onViewClicked() {
        getDatas();
    }
}
